package com.ahy231.service.impl;

import com.ahy231.entity.News;
import com.ahy231.mapper.NewsMapper;
import com.ahy231.service.NewsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

/**
 * @author ahy231
 * @date 2022/3/1 9:39
 * @description
 */
@Service
public class NewsServiceImpl implements NewsService {

    private final NewsMapper newsMapper;

    public NewsServiceImpl(NewsMapper newsMapper) {
        this.newsMapper = newsMapper;
    }

    @Override
    public PageInfo<News> getNews(Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        return PageInfo.of(newsMapper.selectList(new QueryWrapper<>()));
    }
}
